<template>
  <div class="zoom-control">
    <div class="scale-btns">
      <span class="zoom-btn" @click="reduceScale">
        <a-icon-font type="iconjianhao" />
      </span>
      <span class="zoom-btn" @click="addScale">
        <a-icon-font type="iconjiahao" />
      </span>
    </div>
    <span class="vertical-divider"></span>
    <span class="zoom-scale">{{ scaleLevel }}</span>
  </div>
</template>

<script lang="ts">
import { Component, Prop, Vue, Emit } from 'vue-property-decorator'

@Component({
  components: {},
})
export default class GisZoomControl extends Vue {
  @Prop({ type: Number }) getZoom!: number

  private get scaleLevel(): string {
    // return Number(((24 - this.getZoom) / 24).toFixed(3)) * 100
    return this.getZoom.toFixed(2)
  }

  @Emit('scale')
  private addScale() {
    return { type: 'zoomIn' }
  }

  @Emit('scale')
  private reduceScale() {
    return { type: 'zoomOut' }
  }
}
</script>

<style scoped lang="less">
.zoom-control {
  align-items: center;
  background: #fff;
  border: 1px solid #e9e9e9;
  border-radius: 12px;
  bottom: 18px;
  box-sizing: border-box;
  display: flex;
  height: 24px;
  justify-content: flex-end;
  overflow: hidden;
  padding: 0 4px;
  position: absolute;
  right: 24px;
  transition: width 0.3s;
  width: 108px;
  z-index: 100;

  .vertical-divider {
    background-color: #999;
    height: 16px;
    margin: 0 8px;
    width: 1px;
  }

  .zoom-scale {
    color: #5d637e;
    display: inline-block;
    flex-shrink: 0;
    height: 20px;
    line-height: 20px;
    position: relative;
    text-align: center;
    user-select: none;
    width: 39px;
  }

  .scale-btns {
    align-items: center;
    display: flex;
    height: 100%;
    justify-content: space-around;

    .zoom-btn {
      border-radius: 1px;
      cursor: pointer;
      display: inline-block;
      flex-shrink: 0;
      height: 18px;
      line-height: 18px;
      padding: 0 2px;
      text-align: center;
      width: 18px;

      &:hover {
        background-color: rgba(105, 115, 255, 0.1);
        color: #6973ff;
      }
    }
  }
}
</style>
